using System;
using System.Data.Common;
using Microsoft.EntityFrameworkCore.Diagnostics;

namespace CHEnhanceEfCore.Interceptor
{
    /// <summary>
    /// sql执行时的拦截
    /// </summary>
    public class EfCoreInterceptor : DbCommandInterceptor
    {
        public override InterceptionResult<DbDataReader> ReaderExecuting(DbCommand command, CommandEventData eventData, InterceptionResult<DbDataReader> result)
        {
            Console.WriteLine("Intercepted SQL: " + command.CommandText);
            return base.ReaderExecuting(command, eventData, result);
        }
    }
}